import java.util.ArrayList;
import java.util.List;

import org.wizehack.mri.SFLocalizer;
import org.wizehack.mri.fl.SFLAlgorithm;
import org.wizehack.mri.fl.Tarantula;
import org.wizehack.mri.test.TestCase;
import org.wizehack.mri.test.TestSuite;


public class SFLDemoUsingCoverageFile extends SFLocalizer{
	private static String PROJECT_NAME = "GraphEditor_Sim_0";
	private static String SOURCE_CODE_LOCATION = "/home/hsyoun/workspace/jgraphx/src/";
	
	private int NUMBER_OF_TEST_SUITE = 3;

	private static String TEST_SUITE1_DIR = "/home/hsyoun/workspace/jgraphx/ExprData/test_suite_1";
	private static String TEST_SUITE2_DIR = "/home/hsyoun/workspace/jgraphx/ExprData/test_suite_2";
	private static String TEST_SUITE3_DIR = "/home/hsyoun/workspace/jgraphx/ExprData/test_suite_3";

	@Override
	public void setUp() {
		super.createProject(PROJECT_NAME, SOURCE_CODE_LOCATION, NUMBER_OF_TEST_SUITE);
	}

	@Override
	public void registerTestSets() {
		int[] numberOfTestCase = new int[NUMBER_OF_TEST_SUITE];
		
		List<String> failedCoverageFileList = new ArrayList<String>();
		failedCoverageFileList.add(TEST_SUITE1_DIR + "/2-4_fault_vdx.xml");
		failedCoverageFileList.add(TEST_SUITE2_DIR + "/2-5_fault_pagesetup.xml");
		failedCoverageFileList.add(TEST_SUITE3_DIR + "/3-5_fault_about.xml");

		List<String> covFileList1 = this.scanCoverageFile(TEST_SUITE1_DIR);
		TestSuite testSuite1 = this.configureTestSuite(covFileList1, failedCoverageFileList);
		numberOfTestCase[0] = testSuite1.size();
		
		List<String> covFileList2 = this.scanCoverageFile(TEST_SUITE2_DIR);
		TestSuite testSuite2 = this.configureTestSuite(covFileList2, failedCoverageFileList);
		numberOfTestCase[1] = testSuite2.size();

		List<String> covFileList3 = this.scanCoverageFile(TEST_SUITE3_DIR);
		TestSuite testSuite3 = this.configureTestSuite(covFileList3, failedCoverageFileList);
		numberOfTestCase[2] = covFileList3.size();

		this.setNumberOfTestCase(numberOfTestCase);

		this.addTestSuite(testSuite1);
		this.addTestSuite(testSuite2);
		this.addTestSuite(testSuite3);
	}



	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SFLDemoUsingCoverageFile demo = new SFLDemoUsingCoverageFile();
		demo.probe();
		SFLAlgorithm sfl = new Tarantula(); 
		demo.debug(sfl);
	}
}
